<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <%@ include file="/WEB-INF/views/include/head.jsp"%> 
        <script src="${ctxStatic}/js/style.js"></script>
        <link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
        <link rel="stylesheet" href="${ctxStatic}/css/list.css">
        <script type="text/javascript">
			$(document).ready(function(){
				var contractNo = "${contractNo }";
				if (contractNo != null && contractNo != "") {
					searchListForm();
				}
				$("#contractID").select2();
			});	
	               
	    	function searchListForm() {
	    		if ($("#contractID").val() == "") {
					tipParent("请选择定制合同！");
					return;
				}
	    		$("#activity_pane").showLoading();
	    		var params = $("#searchForm").serialize();
	    		$.post("${ctx}/customization/unitcost/searchList",params, function(result) {
	    			var listHtml = result["unitCost"];
	    			var pageHtml = result["page"];
	    			$("#listHtml").html(listHtml);
	    			$("#paging").html(pageHtml);
	    			$("#activity_pane").hideLoading();
	    		}, 'json');
	    	}
	    	//重置
	    	function clean() {
	    		$("input").val("");
	    		$("#contractID").val("");
	    		$("#contractID").select2();
	    		$("#listHtml").html("");
	    		$("#paging").html("");
	    		//searchListForm();
	    	}  
	    	
	    	// 导出
	    	function exportUnit() {
	    		var contractID = $('#contractID').val();
	    		var unitCostStatus = $('#contractID').find("option:selected").attr("unitCost-value");
	    		var contractNo = $("#contractID").find("option:selected").text();
	    		if (contractID == "") {
					tipParent("请选择定制合同！");
					return;
				}
	    		$("#activity_pane").showLoading();
	    		var styleNoFrom = $("#styleNoFrom").val();
	    		var styleNoTo = $("#styleNoTo").val();
	    		/* var shirtSgd = $("#shirtSgd").find("option:selected").val(); 
	    		var orderStatusCD = $("#orderStatusCD").find("option:selected").val(); */
	    		//window.location.href='${ctx}/customization/order/exportFile?contractID='+contractID+'&styleNoFrom='+styleNoFrom+'&styleNoTo='+styleNoTo;
	    		$.post('${ctx}/customization/order/exportFile?contractID='+contractID+'&unitCostStatus='+unitCostStatus+'&styleNoFrom='+styleNoFrom+'&styleNoTo='+styleNoTo,"", function(result) {
					if (result == "true") {
						window.location.href='${ctx}/customization/order/makeExportFile?contractNo='+contractNo;
					}else {
	    				tipParent(result.message);
					}
	    			$("#activity_pane").hideLoading();
	    		}, 'json');
	    	}
	    	//创建出库申请画面
	    	function inventoryRequest(){
	    		var contractID = $("#contractID").val();
	    		popup('900px','584px','${ctx}/customization/unitcost/inventoryRequest?contractID='+contractID);
	    	}
        </script> 
    </head>
    <body>
    <form id="searchForm">
 <div class="listArea" id="activity_pane">
	<div class="listBg">
        <div class="searchArea clearfix">
         <div class="searchInp clearfix">
         	<p class="t">
				<spring:message code="unitCost_export_select_contractNo"/>
			</p>
        	<select id="contractID" name="contractID" style="width: 180px;">
        		<option value=""><spring:message code="unitCost_export_select_pleaseChoose"/></option>
	        	<c:forEach items="${contractList }" var="ct">
	        		<option value="${ct.contractID }" unitCost-value="${ct.unitCostStatus }" <c:if test="${contractNo eq ct.contractNo }">selected="selected"</c:if>>${ct.contractNo }</option>
	        	</c:forEach>
        	</select>    
    		</div>
    		<%-- <div class="searchInp clearfix">
		                    <!-- 日期 -->
		                    <p class="searchTxt"><spring:message code="order_chuanqi"/></p>
		                    <div class="timeBox">
							<input type="text" class="laydate-icon" onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',onpicked:null})"
								id="beginDate" name="beginDate" style="width: 110px" value="${fns:getDate('yyyy-MM-dd')}">
							<p class="list">~</p>
							<input type="text" class="laydate-icon" id="endDate" name="endDate"
								style="width: 110px" onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',onpicked:null})" value="${fns:getDate('yyyy-MM-dd')}">
						    </div>
		                </div>--%>
		                <div class="searchInp clearfix">
		                    <!-- 生产号 -->
		                    <p class="searchTxt"><spring:message code="style_neibu_no"/></p>
		                    <div class="timeBox">
		                   <input class="w-customer"  id="styleNoFrom"  name="styleNoFrom"><p class="list">~</p><input class="w-customer"  id="styleNoTo"  name="styleNoTo">
		                
		                </div>
		                </div> 
                <div class="searchRight clearfix">
                    <!-- 出库申请 -->
						<button type="button" class="btn-js"  onclick="inventoryRequest();">出库申请</button>
                    <shiro:hasPermission name="customization:unitcost:edit">
                	<!-- 导入 -->
		            	<button type="button" class="btn-js"  onclick="popup('500px','150px','${ctx}/customization/unitcost/uploadExcelFile');"><spring:message code="unitCost_export_improtBotten"/></button>
		            </shiro:hasPermission>
		            <shiro:hasPermission name="customization:order:view">
		            <!-- 导出 -->
						<button type="button" class="btn-js"  onclick="exportUnit();"><spring:message code="order_danhao_daochu"/></button>
                    </shiro:hasPermission>
                    <button type="button" id="searchBtn" onclick="searchListForm();"><spring:message code="commom_check"/></button>
                    <button type="button"  onclick="clean();"><spring:message code="material_reset"/></button>
                </div>
            </div>
    
       <div class="tableArea">
				<div class="tableScrollSm" style="overflow: auto;width: 1672px;height: 714px; ">
                    <table cellpadding="0" class="tableHead">
                        <thead>
                            <tr>
	                            <!-- 序号No. -->
	                            <th><p class="width-50px"><spring:message code="common_no"/></p></th>
	                            <!-- 生产号 -->
	                            <th><p class="width-100px"><spring:message code="unitCost_export_styleNo"/></p></th>
	                            <!-- 客户订单号 -->
	                            <th><p class="width-200px"><spring:message code="unitCost_export_orderNo"/></p></th>
	                            <!-- 款式类别 -->
	                            <th><p class="width-100px"><spring:message code="unitCost_export_styleCategory"/></p></th>
	                            <!-- 面料号 -->
	                            <th><p class="width-200px"><spring:message code="unitCost_export_materialCode"/></p></th>
	                            <!-- 面料单耗 -->
	                            <th><p class="width-100px"><spring:message code="unitCost_export_materialUnitCost"/></p></th>
	                            <!-- 扣 -->
	                            <th><p class="width-100px"><spring:message code="unitCost_export_buttonSBU"/></p></th>
	                            <!-- 主商标 -->
	                            <th><p class="width-100px"><spring:message code="unitCost_export_labelPosition"/></p></th>
	                            <!-- 产地标 -->
	                            <th><p class="width-150px"><spring:message code="unitCost_export_countryOfOrigin"/></p></th>
	                            <!-- 洗涤标 -->
	                            <th><p class="width-120px"><spring:message code="unitCost_export_careLabel"/></p></th>
	                            <!-- 面料标 -->
	                            <th><p class="width-120px"><spring:message code="unitCost_export_fabricComposition"/></p></th>
	                            <!-- 小号 -->
	                            <th><p class="width-100px"><spring:message code="unitCost_export_sizeLabel"/></p></th>
	                            <!-- 物料数量 -->
	                            <th><p class="width-100px"><spring:message code="unitCost_export_materialQuantity"/></p></th>
	                            <!-- 明细 -->
	                            <th><p class="width-100px"><spring:message code="unitCost_export_detail"/></p></th>
                            </tr>
                        </thead>
                    </table>
                    <table cellpadding="0" class="tableBody">
					    <tbody  id = "listHtml"></tbody>	
                	</table>
            	</div>
        	</div>
		</div>
		<div id = "paging" ></div>   
      </div>
      </form>
    </body>
</html>